package cn.tanghom.support.web;

import javax.servlet.http.HttpServletRequest;
/**
 * 浏览器设备
 * @author Hunteron-cp
 *
 */
public enum Device {
	pc,android,ios,pad,weixin,mobile;
	
	public boolean isMobile(){
		if(this==android || this==ios || this==mobile || this==weixin){
			return true;
		}
		return false;
	}
	
	public static Device detect(HttpServletRequest request){
		String agent = request.getHeader("User-Agent");			
		if (agent!=null && agent.indexOf("MicroMessenger") != -1) return Device.weixin;
		if (agent!=null && agent.indexOf("Webview") != -1) return Device.mobile;
		if (agent!=null && agent.indexOf("Mobile") != -1) return Device.mobile;
		if (agent!=null && agent.indexOf("iPhone") != -1) return Device.ios;
		return null;		
	}
}
